package index5;

import Listejer.ContainerListener;

import java.awt.Dimension;

import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentListener;

import javax.swing.JFrame;
import javax.swing.JTextField;

public class Numero3
  extends JFrame
{
  private JTextField nomTextField = new JTextField();
  private JTextField adresseTextField = new JTextField();
  private JTextField prenomTextField = new JTextField();
  private JTextField telephoneTextField = new JTextField();

  public Numero3()
  {
    try
    {
      jbInit();
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
  }

  private void jbInit()
    throws Exception
  {
    this.getContentPane().setLayout( null );
    this.setSize( new Dimension(400, 300) );

    nomTextField.setBounds(new Rectangle(90, 15, 205, 35));
    adresseTextField.setBounds(new Rectangle(90, 115, 205, 35));
    prenomTextField.setBounds(new Rectangle(90, 65, 205, 35));
    telephoneTextField.setBounds(new Rectangle(90, 165, 205, 35));
    this.getContentPane().add(telephoneTextField, null);
    this.getContentPane().add(prenomTextField, null);
    this.getContentPane().add(adresseTextField, null);
    this.getContentPane().add(nomTextField, null);
    EcouteurDeFenetre ec = new EcouteurDeFenetre();
    
    nomTextField.addActionListener(ec);
    prenomTextField.addActionListener(ec);
    telephoneTextField.addActionListener(ec);
    adresseTextField.addActionListener(ec);
  
  }
  private class EcouteurDeFenetre implements ActionListener
  {
    public void actionPerformed(ActionEvent e)
    {
      if (e.getSource().equals(nomTextField))
        prenomTextField.requestFocus();
      else if((e.getSource().equals(prenomTextField))) 
        adresseTextField.requestFocus();
      else if ((e.getSource().equals(adresseTextField))) 
        telephoneTextField.requestFocus();
    }
  }
}
